' ****** START INCLUDE Rgba Core ******
DIM r0%, g0%, b0%, a0%, r1%, g1%, b1%, a1%

SUB SetRgb0(x%,y%)
    DIM c$
    c$ = RIGHT$("000000" + HEX$(POINT(x%,y%)), 6)
    r0% = VAL("0x" + LEFT$(c$,2))
    g0% = VAL("0x" + MID$(c$,3,2))
    b0% = VAL("0x" + RIGHT$(c$,2))
END SUB

SUB SetRgb1(c&,a%b)
    DIM c$
    c$ = RIGHT$("000000" + HEX$(c&), 6)
    r1% = VAL("0x" + LEFT$(c$,2))
    g1% = VAL("0x" + MID$(c$,3,2))
    b1% = VAL("0x" + RIGHT$(c$,2))
    a0% = 255 - a%b
    a1% = a%b
END SUB

SUB RgbaCorePset(x%,y%)
    PSET(x%,y%), _RGB( [{ (r0%*a0%)+(r1%*a1%) }/255], [{ (g0%*a0%)+(g1%*a1%) }/255], [{ (b0%*a0%)+(b1%*a1%) }/255] )
END SUB
'  ****** END INCLUDE Rgba Core ******

aspect_ratio = 1

Sub RgbaCircle (xc%, yc%, r%, c&, a%b)

    DIM xy&, a&, a_ar&, xy_ar&, y%, x%, x1%, x2%, bFound%
    FOR xy& = 0 TO r%*0.75
        a& = SQR( r% * r% - xy& * xy& )
        a_ar& = a&/aspect_ratio
        xy_ar& = xy&/aspect_ratio
        PSET (xc% + xy&, yc% - a_ar&), &h000001
        PSET (xc% - xy&, yc% - a_ar&), &h000001
        PSET (xc% + xy&, yc% + a_ar&), &h000001
        PSET (xc% - xy&, yc% + a_ar&), &h000001
        PSET (xc% - a&, yc% + xy_ar&), &h000001
        PSET (xc% - a&, yc% - xy_ar&), &h000001
        PSET (xc% + a&, yc% + xy_ar&), &h000001
        PSET (xc% + a&, yc% - xy_ar&), &h000001
    NEXT xy&
    
    SetRgb1(c&, a%b)
    For y% = yc% - r% - 3 TO  yc% + r% + 3
        x1% = xc% - r% - 2
        bFound% = FALSE
        WHILE bFound% = FALSE AND x1% < xc% + r% + 3
           WHILE POINT(x1% + 1, y%) = &h000001 : bFound% = TRUE : x1% = x1% + 1 : WEND
           IF bFound% = FALSE THEN x1% = x1% + 1
        WEND
        If bFound% THEN
          x2% = x1%
          bFound% = FALSE
          WHILE bFound% = FALSE AND x2% < xc% + r% + 3
             IF POINT(x2% + 1, y%) = &h000001 THEN bFound% = TRUE ELSE x2% = x2% + 1
          WEND
          If (bFound% = TRUE) AND ( x2% > (x1%) ) THEN
              FOR x% = x1% + 1 TO x2% : SetRgb0(x%,y%) : RgbaCorePset(x%,y%) : NEXT x%
          END IF
        END IF
    Next x%
END SUB

screen _newimage(300, 151, 27)

color , &h505050
cls

for y = 0 to 150 step 4
line (0, y) - (299, y ), &hFFFFFF
next y
RgbaCircle (80, 70, 63, &hFF0000, 150)
RgbaCircle (210, 70, 63, &h00FF00, 150)

END